Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-util

Package Overview
Dependencies
Maintainers
7
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-util

Common Utils For React Component

  • 4.21.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created

What is rc-util?

The rc-util npm package is a collection of utility functions and components designed to be used with React components. It provides a set of tools to help with common tasks in React development such as DOM manipulation, event handling, and component management.

What are rc-util's main functionalities?

DOM manipulation

This feature allows you to get the scroll position of an element or the window. It is useful for handling scroll-related logic in your React components.

import { getScroll } from 'rc-util/lib/Dom/scroll';

const scrollPosition = getScroll(window);
console.log(scrollPosition);

Event handling

This feature provides a way to add and remove event listeners. It is particularly useful for setting up event listeners with the capability to easily remove them later, preventing potential memory leaks.

import { addEventListener } from 'rc-util/lib/Dom/addEventListener';

const removeListener = addEventListener(window, 'resize', () => {
  console.log('Window resized');
});

// To remove the event listener
removeListener();

KeyCode utilities

KeyCode utilities provide a convenient set of constants for key codes, which can be used to improve the readability and maintainability of code that involves keyboard event handling.

import KeyCode from 'rc-util/lib/KeyCode';

const isEnterPressed = (event) => {
  return event.keyCode === KeyCode.ENTER;
};

Other packages similar to rc-util

Keywords

FAQs

Package last updated on 29 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc